package cn.stylefeng.guns.modular.manager.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.manager.entity.ArchiveInfo;
import cn.stylefeng.guns.modular.manager.model.params.ArchiveInfoParam;
import cn.stylefeng.guns.modular.manager.service.ArchiveInfoService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 档案信息表控制器
 *
 * @author blesslp
 * @Date 2019-11-20 11:38:17
 */
@Controller
@RequestMapping("/archiveInfo")
public class ArchiveInfoController extends BaseController {

    private String PREFIX = "/manager/archiveInfo";

    @Autowired
    private ArchiveInfoService archiveInfoService;

    /**
     * 跳转到主页面
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/archiveInfo.html";
    }

    /**
     * 跳转到主页面
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/dialog")
    public String dialog() {
        return PREFIX + "/archiveInfo_dialog.html";
    }

    /**
     * 新增页面
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/archiveInfo_add.html";
    }

    /**
     * 新增页面-批量录入用
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/add2")
    public String add2() {
        return PREFIX + "/archiveInfo_add2.html";
    }
    /**
     * 编辑页面-批量录入用
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/edit2")
    public String edit2() {
        return PREFIX + "/archiveInfo_edit2.html";
    }


    /**
     * 批量新增页面
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/batAdd")
    public String batAdd() {
        return PREFIX + "/archiveInfo_batAdd.html";
    }

    /**
     * 编辑页面
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/archiveInfo_edit.html";
    }

    /**
     * 新增接口
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ArchiveInfoParam archiveInfoParam) {
        final ArchiveInfo add = this.archiveInfoService.add(archiveInfoParam);
        return ResponseData.success(add);
    }

    /**
     * 编辑接口
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ArchiveInfoParam archiveInfoParam) {
        final ArchiveInfo update = this.archiveInfoService.update(archiveInfoParam);
        return ResponseData.success(update);
    }

    /**
     * 删除接口
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ArchiveInfoParam archiveInfoParam) {
        this.archiveInfoService.delete(archiveInfoParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ArchiveInfoParam archiveInfoParam) {
        ArchiveInfo detail = this.archiveInfoService.getById(archiveInfoParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ArchiveInfoParam archiveInfoParam) {
        return this.archiveInfoService.findPageBySpec(archiveInfoParam);
    }

    /**
     * 查询列表
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @ResponseBody
    @RequestMapping("/listNoBorrow")
    public LayuiPageInfo listNoBorrow(ArchiveInfoParam archiveInfoParam) {
        return this.archiveInfoService.findNoBorrowList(archiveInfoParam);
    }

    /**
     * 查询列表
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @ResponseBody
    @RequestMapping("/listBorrow")
    public LayuiPageInfo listBorrow(Long id) {
        return this.archiveInfoService.findBorrowList(id);
    }


    /**
     * 查询已销毁的档案列表
     *
     * @author blesslp
     * @Date 2019-11-20
     */
    @ResponseBody
    @RequestMapping("/listDestroy")
    public LayuiPageInfo listDestroy(Long id) {
        return this.archiveInfoService.listDestroy(id);
    }


    @ResponseBody
    @RequestMapping("/groupByNd")
    public ResponseData groupByNd() {
        return ResponseData.success(this.archiveInfoService.groupByNd());
    }

    @ResponseBody
    @RequestMapping("/groupByBm")
    public ResponseData groupByBm() {
        return ResponseData.success(this.archiveInfoService.groupByBm());
    }

    @ResponseBody
    @RequestMapping("/groupByDa")
    public ResponseData groupByDa() {
        return ResponseData.success(this.archiveInfoService.groupByDah());
    }

}


